package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.dg.DgCompleteRequest;
import com.trhui.mallbook.domain.request.hf.HfCompleteRequest;
import com.trhui.mallbook.domain.request.yb.YbCompleteRequest;
import com.trhui.mallbook.domain.response.dg.DgCompleteResponse;
import com.trhui.mallbook.domain.response.hf.HfCompleteResponse;
import com.trhui.mallbook.domain.response.yb.YbCompleteResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * 异步分账接口
 *
 * @Author xgc
 * @Date 2023/08/22 16:22
 **/
public class CompleteClient extends AbstractClient {
    /**
     * 汇付异步接口
     *
     * @param request 汇付异步请求对象
     * @return
     */
    public static BaseResponse<HfCompleteResponse> hfComplete(HfCompleteRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.COMPLETE)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfCompleteResponse.class);
    }

    /**
     * 易宝异步接口
     *
     * @param request 易宝异步请求对象
     * @return
     */
    public static BaseResponse<YbCompleteResponse> ybComplete(YbCompleteRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.COMPLETE)
                .channelType(ChannelTypeEnum.YB)
                .build();
        return post(apiRequest, YbCompleteResponse.class);
    }

    /**
     * 斗拱异步接口
     *
     */
    public static BaseResponse<DgCompleteResponse> dgComplete(DgCompleteRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.COMPLETE)
                .channelType(ChannelTypeEnum.DG)
                .build();
        return post(apiRequest, DgCompleteResponse.class);
    }

}
